//
//  LAGGeometry.m
//  LAMapBasicDemo
//
//  Created by 罗亮富 on 2018/1/8.
//  Copyright © 2018年 2Bulu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LAGGeometry.h"


inline double calculateDistanceBetweenLocations(CLLocation *p1, CLLocation *p2, bool accountAltitude)
{
    double distance = 0;
    if(accountAltitude)
    {
        distance = get_distanceAccountAltitude(p1.coordinate.latitude, p1.coordinate.longitude, p1.altitude, p2.coordinate.latitude, p2.coordinate.longitude, p2.altitude);
    }
    else
    {
        distance = get_distance(p1.coordinate.latitude, p1.coordinate.longitude, p2.coordinate.latitude, p2.coordinate.longitude);
    }
    return distance;
}


CLLocation *objcLocationFromPoint(LocationPointType point)
{
    NSDate *time = nil;
    if(fabs(point.timeInterval) > 0.1)
        time = [NSDate dateWithTimeIntervalSince1970:point.timeInterval];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
    CLLocation *loc = [[CLLocation alloc]initWithCoordinate:CLLocationCoordinate2DMake(point.latitude, point.longitude) altitude:point.altitude horizontalAccuracy:point.accuracy verticalAccuracy:0 course:0 speed:point.speed timestamp:time];
#pragma clang diagnostic pop
    
    return loc;
}

MKMapPoint LAMapPointFromPointDataType(LocationPointType point)
{
    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DFromPointDataType(point);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
    return MKMapPointForCoordinate(coordinate);
#pragma clang diagnostic pop
}
